package com.tcm.common.handler;

import com.tcm.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务类
 *
 * @author Guqier
 * @version 1.0
 * @date 2023/7/8 14:31
 */
@Component
public class ScheduledTask {

    @Autowired
    private ScoreService scoreService;

    /**
     * 定时更新学生积分排行榜
     */
    @Async
    @Scheduled(cron = "0 0 0/1 * * ? ")// 每隔一小时更新一次
    public void executeSaveStudentRank() {
        scoreService.saveStudentRankToCache();
    }

    /**
     * 定时更新社会化学员积分排行榜
     */
    @Async
    @Scheduled(cron = "0 0 0/1 * * ? ")// 每隔一小时更新一次
    public void executeSaveSocialStudentRank() {
        scoreService.saveSocialStudentRankToCache();
    }

}
